package com.yanqu.road.server.pb;

import com.yanqu.road.entity.activity.xiayue.XiaYueUserData;
import com.yanqu.road.entity.activity.xiayue.config.XiaYueAnimalConfig;
import com.yanqu.road.entity.activity.xiayue.config.XiaYueCombConfig;
import com.yanqu.road.entity.activity.xiayue.config.XiaYueConfig;
import com.yanqu.road.entity.activity.xiayue.config.XiaYueNpcConfig;
import com.yanqu.road.entity.activity.xiayue.config.XiaYuePlaceConfig;
import com.yanqu.road.pb.activity.XiaYueActivityProto;
import com.yanqu.road.server.manger.ServerLanguageMgr;
import com.yanqu.road.utils.property.PropertyHelper;

public class XiaYuePb {

    public static XiaYueActivityProto.XiaYueSyncConfigRespMsg.Builder parseXiaYueSyncConfigRespMsg(XiaYueConfig config, String language) {
        XiaYueActivityProto.XiaYueSyncConfigRespMsg.Builder builder = XiaYueActivityProto.XiaYueSyncConfigRespMsg.newBuilder();
        for (XiaYuePlaceConfig placeConfig : config.getPlaceConfigMap().values()) {
            builder.addPlaceConfigList(parseXiaYuePlaceConfigMsg(placeConfig, language));
        }
        for (XiaYueAnimalConfig animalConfig : config.getAnimalConfigMap().values()) {
            builder.addAnimalConfigList(parseXiaYueAnimalConfigMsg(animalConfig, language));
        }
        for (XiaYueCombConfig combConfig : config.getCombConfigMap().values()) {
            builder.addCombList(parseXiaYueCombConfigMsg(combConfig, language));
        }
        for (XiaYueNpcConfig npcConfig : config.getNpcConfigList()) {
            builder.addNpcList(parseXiaYueNpcConfigMsg(npcConfig, language));
        }
        return builder;
    }

    public static XiaYueActivityProto.XiaYuePlaceConfigMsg.Builder parseXiaYuePlaceConfigMsg(XiaYuePlaceConfig config, String language) {
        XiaYueActivityProto.XiaYuePlaceConfigMsg.Builder builder = XiaYueActivityProto.XiaYuePlaceConfigMsg.newBuilder();
        builder.setPlaceId(config.getId());
        builder.setName(ServerLanguageMgr.getContent(config.getName(), language));
        builder.setDesc(ServerLanguageMgr.getContent(config.getDesc(), language));
        builder.addAllAnimalList(config.getAnimalList());
        builder.addAllWeightList(config.getWeightList());
        return builder;
    }

    public static XiaYueActivityProto.XiaYueAnimalConfigMsg.Builder parseXiaYueAnimalConfigMsg(XiaYueAnimalConfig config, String language) {
        XiaYueActivityProto.XiaYueAnimalConfigMsg.Builder builder = XiaYueActivityProto.XiaYueAnimalConfigMsg.newBuilder();
        builder.setAnimalId(config.getId());
        builder.setName(ServerLanguageMgr.getContent(config.getName(), language));
        builder.setDesc(ServerLanguageMgr.getContent(config.getDesc(), language));
        builder.setQuality(config.getQuality());
        builder.setScore(config.getScore());
        return builder;
    }

    public static XiaYueActivityProto.XiaYueNpcConfigMsg.Builder parseXiaYueNpcConfigMsg(XiaYueNpcConfig config, String language) {
        XiaYueActivityProto.XiaYueNpcConfigMsg.Builder builder = XiaYueActivityProto.XiaYueNpcConfigMsg.newBuilder();
        builder.setNpcId(config.getNpcId());
        builder.setName(ServerLanguageMgr.getContent(config.getName(), language));
        builder.setDesc(ServerLanguageMgr.getContent(config.getDesc(), language));
        return builder;
    }

    public static XiaYueActivityProto.XiaYueCombConfigMsg.Builder parseXiaYueCombConfigMsg(XiaYueCombConfig config, String language) {
        XiaYueActivityProto.XiaYueCombConfigMsg.Builder builder = XiaYueActivityProto.XiaYueCombConfigMsg.newBuilder();
        builder.setCombId(config.getCombId());
        builder.setName(ServerLanguageMgr.getContent(config.getName(), language));
        builder.addAllElement(config.getElementList());
        builder.setSort(config.getSort());
        return builder;
    }

    public static XiaYueActivityProto.XiaYueSyncUserDataRespMsg.Builder parseXiaYueSyncUserDataRespMsg(XiaYueUserData userData) {
        XiaYueActivityProto.XiaYueSyncUserDataRespMsg.Builder builder = XiaYueActivityProto.XiaYueSyncUserDataRespMsg.newBuilder();
        builder.setAnimalProp(PropertyHelper.parsePropertyToString(userData.getAnimalProp()));
        builder.addAllNpcList(userData.getNpcList());
        builder.setCurPlace(userData.getCurPlace());
        return builder;
    }

    public static XiaYueActivityProto.XiaYueSearchDataMsg.Builder parseXiaYueSearchDataMsg(int placeId, int animalId, int addNpcId) {
        XiaYueActivityProto.XiaYueSearchDataMsg.Builder builder = XiaYueActivityProto.XiaYueSearchDataMsg.newBuilder();
        builder.setPlaceId(placeId);
        builder.setAnimalId(animalId);
        builder.setAddNpcId(addNpcId);
        return builder;
    }
}
